Simple C Programming examples - The Incredible Truth


Simple C-Programming Examples  with Output ⇒




1st Program: 


#include <stdio.h>    /*linking section*/
#include <conio.h>
void main()    /*program section*/
{
int X=10;
clrscr();
{
int X=15;
printf(“\n X: %d”, X);
}
printf(“\n Value of X: %d”, X);
getch();
}

Output:

X: 15
Value of X: 10


2nd Program:



#include <stdio.h>    /*linking section*/
#include <conio.h>
void main()    /*program section*/
{
int X, Y, Z;
clrscr();
printf(“\n Enter the value:”);
scanf(“%2d%2d%4d”, &X, &Y, &Z);
printf(“\n X:%d Y:%d Z:%d”, X,Y,Z);
getch();
}

Output: (As per your requirement)

Enter the value: 12345678
X: 12
Y: 34
Z: 5678

Or if,

Enter the value: 1234567
X: 12
Y: 34
Z: 567

See Also:

Addition of two numbers with C-Programming

Introduction to C-Programming

Comments

Post a Comment

Popular Posts