Find Average of Two Numbers : C Program

Computer Science » C Program » Find Average of Two Numbers

Program :

#include <stdio.h>
int main()
{
    int num1, num2;
    float avg;

    printf("nEnter first number : ");
    scanf("%d",&num1);

    printf("nEnter second number : ");
    scanf("%d",&num2);

    avg= (float)(num1+num2)/2;
    printf("nAverage of %d and %d is : %f",num1,num2,avg);

    return 0;
}

Output :

Enter first number : 5
Enter second number : 3
Average of 5 and 3 is : 4.00
Subject Name : Computer Science
Exam Name : IIT GATE, UPSC ESE, RRB, SSC, DMRC, NMRC, BSNL, DRDO, ISRO, BARC, NIELIT
Posts Name : Assistant Engineer, Management Trainee, Junior Engineer, Technical Assistant
Computer Science Books

GATE 2023 Total InfoENGG DIPLOMAUGC NET Total Info
IES 2023 Total InfoPSUs 2022 Total InfoCSIR UGC NET Total Info
JAM 2023 Total InfoM TECH 2023 Total InfoRAILWAY 2022 Total Info

Related Posts

  • Find greatest in 3 numbers : C ProgramComputer Science » C Program » Find greatest in 3 numbers  Program : [php]#include&lt;stdio.h&gt; int main() { int a, b, c; printf(&quot;nEnter value of a, b &amp; c : &quot;); scanf(&quot;%d %d %d&quot;, &amp;a, &amp;b, &amp;c); if ((a &gt; b) &amp;&amp; (a &gt; c)) printf(&quot;na is greatest&quot;); if ((b &gt; c) &amp;&amp; (b &gt; a)) printf(&quot;nb is greatest&quot;); if ((c &gt; a) &amp;&amp; (c &gt; b)) printf(&quot;nc is greatest&quot;); return(0); }[/php] Output : [php]Enter value for a,b &amp; c : 12 16 20 c is greatest[/php]
    Tags: program, find, numbers, computer, science, output, programs
  • Rectangle using Line and Special Symbols : C ProgramComputer Science » C Program » Rectangle using Line and Special Symbols Program : [php]#include<stdio.h> int main() { int i, j; for (i = 0; i < 10; i++) { printf("n"); for (j = 0; j < 10; j++) { if (i == 0 || i == 9 || j == 0 || j == 9) printf("▲"); else printf("-"); } } return (0); }[/php] Output : [php]▲▲▲▲▲▲▲▲▲▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲▲▲▲▲▲▲▲▲▲[/php]
    Tags: program, computer, science, output, programs
  • Check if a Number is Divisible by 3 : C ProgramComputer Science » C Program » Check if a Number is Divisible by 3 Program : [php]#include<stdio.h> int main() { int number; printf("Enter a number : "); scanf("%d",&number); if ((number % 3) == 0) printf("n%d is a multiple of 3.",number); else printf("n%d is not a multiple of 3.",number); return 0; }[/php] Output 1: [php]Enter a number : 9 9 is a multiple of 3.[/php] Output 2: [php]Enter a number : 8 8 is not a multiple of 3.[/php]
    Tags: program, output, computer, science, programs
  • Print All Prime Numbers between 1 and 100 : C ProgramComputer Science » C Program » Print All Prime Numbers between 1 and 100 Program : [php]#include <stdio.h> int main() { int number,j,flag; printf(" The prime numbers between 1 and 100 : n"); for(number=2;number<=100;number++) { flag=0; for(j=2;j<=number/2;j++) { if(number % j == 0) { flag = 1; break; } } if(flag==0) printf("n %d ",number); } return 0; }[/php] Output : [php]The prime numbers between 1 and 100 : 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 [/php]
    Tags: program, numbers, computer, science, output, programs
  • Check if Number is Odd or Even : C ProgramComputer Science » C Program » Check if Number is Odd or Even Program : [php]#include<stdio.h> int main() { int n; printf("nEnter a number : "); scanf("%d",&n); if ( n%2 == 0 ) printf("n%d is an even number.", n); else printf("n%d is an odd number.", n); return 0; }[/php] Output 1: [php]Enter an number : 122 122 is an even number.[/php] Output 2: [php]Enter an number : 123 123 is an odd number.[/php]
    Tags: program, output, computer, science, programs

LEAVE A REPLY

Please enter your comment!
Please enter your name here