Sunday, 6 January 2019

Celsius To Fahrenheit with c program[c programming examples with output]

C programming examples with output

Celsius To Fahrenheit
Program

#include<stdio.h>
#include<conio.h>
void main()
{
     float c,f;
     clrscr();
     printf("Enter temperature in centigrade: ")
     scanf("%f",&c);
     f=(1.8*c)+32;
     printf("Temperature in Fahrenheit= %f",f);
     getch();
}

Output:
Enter temp in centigrade:100
Temperature in Fahrenheit=212

Saturday, 5 January 2019

Program to print anything without using semicolon ';'[c programming examples with output]

C programming examples with output

Program to print anything without using semicolon ';'
Program

#include<stdio.h>
#include<conio.h>
void main()
{
      while(!printf("Welcome to MoTech360"))
{

}
}

Output:
Welcome to MoTech360



Prime number below a range[c programming examples with output]

C programming examples with output

Prime number below a range
Program

#include<stdio.h>
#include<conio.h>
main()
{
      int a,b,c=0,r;
      clrscr();
      printf("Enter range  :");
      scanf("%d",&r);
      a=1;
      while(a<=r)
      {
         b=1;c=0;
      while(b<=a)
      {
         if(a%b==0)
         c=c+1;
         b++;
      }
         if(c==2)
         printf("\n%d is a prime number",a);
         a++;
      }
      getch():
}

Output
Enter range:20
2 is a prime number
3 is a prime number
5 is a prime number
7 is a prime number
11 is a prime number
13 is a prime number
17 is a prime number
19  is a prime number

Find Static Variables[c programming examples with output]

C programming examples with output

Find Static Variables
Program

#include<stdio.h>
#include<conio.h>
main()
{
     int c;
     clrscr();
     for(c=1;c<=3;c++)
     stat();
     getch();
     }
     stat()
     {
     static int sv=0;
     sv=sv+1;
     printf("%d",sv);
}

Output
1
2
3