Menu

Numbers Pattern Program in C Using for loop ||Explanation||


Pattern Program in C

Hello, a student here you will learn about the “Number Pattern Program in C Using For(): loop I hope this will helps you A lot.

Pattern program in C using numbers

#include<stdio.h>
#include<conio.h>

void main()
{
int i,c=0;
clrscr();
printf("\n enter a number:-");
scanf(" %d",&i);

for(;i>=0;i--)
{
c=i;
printf("\n");
for(;;)
{
printf("%d",c);
if(c==0)
break;
c--;
}
}
getch();

}

Pattern program in C language

Output:-

Enter Any Number:-
Run Time:-

Pattern Program in C

Pattern Program in C

Pattern program in C language using for loop

Result:-

Pattern Program in C

Pattern Program in C

Pattern program in C with explanation

Main Point for This Program?

#include:- That we know in every program we are using #include that is Preprocessor.

<stdio.h> :- It is a Header File whose extension is .h ‘or’ Standard Input/Output.

<conio.h> :- Conio stands for Console Input/Output. It is also a header file, we use it for Clear Output.

void main():- Main is a function and It executes a C program. Only one main function must be present in a C program file.

{ }:- we use it to separate the Particular Block.

Int (Datatype):- It is a Datatype, which storage capacity is 2 Bytes.

I,C (Variable):- Variable must be declared before using then in the declaration portion of the C program. Variable can be declared as Local ‘or’ Global Variables.
Ex. Var1,Var2….VarN; or Int a,b,c; (Here you can also put value in these Variable like Int a,b,c=5)

; (Semicolon):- It is also an important part of every C program. Because in the C program every statement is terminated by Semicolon.

Note:- Here escape sequence ‘/n’ is used to move the cursor in the output window.

Necessary Topics.

Q. Why use clrscr();?
Ans:- clrscr(); stands for Clear Screen, in every C program we can use this function for clear the output screen. we attach it bottom of <Data type section> & top of printf(); or scanf(); .

printf(); :- In C it’s provides function ‘printf(); to Display output on Monitor.

scanf(); :-‘C’ provides function scanf(); for reading the value.
scanf(“%d”,&i); (Here %d is Conversion Character of Integer Datatype & i is variable).

For() :- It is a loop. A loop is also called interaction to execute a set of statements at a number of times. In this loop, the control of the C program initializes a counter variable by a value. After that, it goes to check the given condition. If the value of condition will be true, it executes all those statements written within the block of for() loop after that is goes to increase or decrease the value of a counter variable and again it goes to check the given condition the value of condition will be true again. It goes to execute the block of for() loop. The above task accept initialization is done repeatedly fill the value of condition will be true and when the value of condition will be false the control of C program exit from the for a () loop.

If( ) :- This is conditional statement which gives a condition. Those control statement which is used to transfer the control of C program from One Position to another Position according to the value of the condition. That is called Conditional Statement ‘or’ Conditional Control Statement

Break; :- Break keyword that is used to terminate the execution of Switch-Case statement as well as any type of loop.

C– (Postfix Decrements Operator) :- When a Decrements operator – – is written after a variable name, then it is called Post-fix Decrements Operator. Due to the use of Post-fix Decrements Operator in a statement ‘or’ an Expression then execution will be at 1st and Decentralization at Last.

Why use getch(); in c program?
Ans:-It is an Input statement function, which is used to input data from the Keyboard/File and store the supplied data into variables is called Input statement/Function. In C program if you will use header file as <conio.h> then you have to necessary to use getch(); or return 0; if any case you don’t use this, then our compiler can not understand what to do, Because of the header file <conio.h>, conio stands for Console Input/Output so the C compiler will be confused.

Hello Dear, I hope you will enjoy this Article, Pattern Program in C if you want to learn more Briefly then you can Read this Article Visit again.

Thank You

Numbers Pattern Program in C Using for loop ||Explanation|| - TheSmolt

Pattern Program in C, Here you learn how to make A Number pattern program in C. We describe every statement line-by-line, That helps you in understanding...

Course Provider: Organization


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Learn For Free.