0% found this document useful (0 votes)
60 views17 pages

Sameer Sir Classes, Jabalpur Auth Exam Center Oracle, Microsoft 9407077858

The document contains C code snippets for printing patterns like stars, triangles, and numbers using loops. It discusses different approaches to print patterns by varying the loop conditions and number of nested loops. Examples include printing patterns forward, backward, with spaces, and increasing/decreasing number of stars in each row.

Uploaded by

Divyansh Rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views17 pages

Sameer Sir Classes, Jabalpur Auth Exam Center Oracle, Microsoft 9407077858

The document contains C code snippets for printing patterns like stars, triangles, and numbers using loops. It discusses different approaches to print patterns by varying the loop conditions and number of nested loops. Examples include printing patterns forward, backward, with spaces, and increasing/decreasing number of stars in each row.

Uploaded by

Divyansh Rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Sameer Sir Classes, Jabalpur

Auth Exam Center Oracle, Microsoft


9407077858
1. n=3

*
**
***
printf("*");

#include<stdio.h>
int main()
{
int n , i , j ;

printf(" ENTER NO OF ROWS \n ");


scanf("%d" , &n);

for( i = 1 ; i <= n ; i++ )


{
for( j = 1;j <= i ; j++)
{
printf("*");

} // j

printf("\n");

} // i

}
Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL
Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
2. n=3

***
**
*

for ( i = n ; i >= 1 ; i-- )

---------------------------------------------------------------------

n=3

i = 3 to 1

i = 3 j = 1 to 3

j=1 ***

j=2

j=3

--------------------------

i = 2 j = 1 to 2

j=1 **

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
j=2
-------------------------
i = 1 j = 1 to 1

j=1 *
--------------------------------------------------------------------
*/

#include<stdio.h>

int main()
{
int n , i , j ;

printf(" ENTER NO OF ROWS \n ");


scanf("%d" , &n);

for( i = n ; i >= 1 ; i-- )


{
for( j = 1 ; j <= i ; j++)
{
printf("*" ) ;

printf("\n");
}
}
Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL
Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
3.
N=3

*
**
***
#include<stdio.h>
int main()
{
int i , j , k , n ;
printf(" ENTER NO. OF ROWS \n ");
scanf("%d", &n);

for( i = 1 ; i <= n ; i++ )


{
for( k = 1 ; k <= (n-i) ; k++) // for spaces
{
printf(" ");
} // k (imp)

for( j = 1 ; j <= i ; j++)


{
printf("*");
} // j
printf("\n");
} // i
}

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
4. N=3

***
**
*
#include<stdio.h>
int main()
{
int i , j , k , n ;

printf(" ENTER NO. OF ROWS \n ");


scanf("%d", &n);

for( i = n ; i >= 1 ; i-- )


{

for( k = 1 ; k <= (n-i) ; k++) // for spaces


{
printf(" ");
} // k (imp)

for( j = 1 ; j <= i ; j++)


{
printf("*");
} // j
printf("\n");
} // i
}
Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL
Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
5.
N=3

*
* *
* * *
#include<stdio.h>
int main()
{
int i , j , k , n ;
printf(" ENTER NO. OF ROWS \n ");
scanf("%d", &n);

for( i = 1 ; i <= n ; i++ )


{
for( k = 1 ; k <= (n-i) ; k++) // for spaces
{
printf(" ");
} // k (imp)

for( j = 1 ; j <= i ; j++)


{
printf("*"); printf(“ “);
} // j
printf("\n");
} // i
}

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
4. N=3

* * *
* *
*
#include<stdio.h>
int main()
{
int i , j , k , n ;

printf(" ENTER NO. OF ROWS \n ");


scanf("%d", &n);

for( i = n ; i >= 1 ; i-- )


{

for( k = 1 ; k <= (n-i) ; k++) // for spaces


{
printf(" ");
} // k (imp)

for( j = 1 ; j <= i ; j++)


{
printf("*"); printf(“ “);
} // j
printf("\n");
} // i
}
Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL
Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
7. n=3
*
** *
*** *
#include<stdio.h>
int main()
{
int i , j , k , n ;

printf(" ENTER NO. OF ROWS \n ");


scanf("%d", &n);

for( i = 1 ; i <=n ; i++)


{
for( k = 1 ; k <= (n -i) ; k++)
{
printf(" ");
} // k --> for space

for( j = 1 ; j <=(2*i-1) ; j++)


{
printf("*");
}
printf("\n");

}
Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL
Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
n=3

for i = 1 to 3
i = 1 k = 1 to 2

k=1

k=2

j = 1 to 1

j=1 *

-----------------------------
i = 2 k = 1 to 1

k=1

j = 1 to 3

j=1

j=2

j=3 ***

----------------------------------
i = 3 k = 1 to 0
Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL
Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858

j = 1 to 5

j=1

j=2

j=3

j=4

j=5 *****

--------------------------------------------------------------------

8. n = 4

********
*****
***
*

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
#include<stdio.h>
int main()
{
int i , j , k , n ;

printf(" ENTER NO. OF ROWS \n ");


scanf("%d", &n);

for( i = n ; i >=1 ; i--)


{
for( k = 1 ; k <= (n -i) ; k++)
{
printf(" ");
} // k --> for space

for( j = 1 ; j <=(2*i-1) ; j++)


{
printf("*");
}
printf("\n");
}

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
9.
n=4

*
***
*****
*******
*****
***
*
#include<stdio.h>

int main()
{
int i,j, k, n ;

printf("enter n\n");

scanf("%d", &n);

for(i= 1; i<=n ; i++) // 1


{
for ( k =1 ;k <= n-i ; k++)
{
printf(" "); // for spaces
}
for(j= 1 ; j <= (2*i-1) ; j++)
{
Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL
Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858

printf("*");
}
printf("\n");

for(i=n-1; i>=1; i--) // 2


{
for ( k =1 ;k <= n-i ; k++)
{
printf(" "); // for spaces
}
for(j= 1;j <= (2*i-1) ; j++)
{

printf("*");
}
printf("\n");

}
}
/*

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
-----------------------------------------------------------------------

10. n=4

*******
*****
***
*
***
*****
*******

------------------------------------------------------------------------
*/

#include<stdio.h>

int main()
{

int i,j, k, n ;

printf("enter n\n");

scanf("%d", &n);

for(i=n; i>=1; i--)

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858
{
for ( k =1 ;k <= n-i ; k++)
{
printf(" "); // for spaces
}
for(j= 1 ; j <= (2*i-1) ; j++)
{

printf("*");
}
printf("\n");

for(i= 2; i<=n ; i++)


{
for ( k =1 ;k <= n-i ; k++)
{
printf(" "); // for spaces
}
for(j= 1;j <= (2*i-1) ; j++)
{
printf("*");
}
printf("\n");
}
}

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com
Sameer Sir Classes, Jabalpur
Auth Exam Center Oracle, Microsoft
9407077858

Training for – Programming in C, Cpp, DSA, Java, Python,Linux,Oracle SQL


Internship, Industrial Training, Project Development
https://imgjbp.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy