Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Monday, 6 June 2016

PROBLEM 40:
Take obtained marks of a student out of 100 as input and print the grade as per following rules.
(Use both a) Positive and b) Negative Logic):
Obtained Marks
Grade
Between and including 50 and 60
D
Between and including 61 and 70
C
Between and including 71 and 80
B
Between and including 81 and 90
A-
Between and including 91 and 100
A+

Code:
#include<stdio.h>
main()
{
    // Variable declaration//
    int marks;
   /*Input*/
    printf("enter your marks:");
    scanf("%d",&marks);
     /* actual Working */
    if(marks>=50 && marks<=60)
    {
        printf("your grade is D");
    }
    else if(marks>=61 && marks<=70)
    {
        printf("your grade is C");
    }
    else if(marks>=71 && marks<=80)
    {
        printf("your grade is B");
    }
    else if(marks>=81 && marks<=90)
    {
        printf("your grade is A");
    }
    else if(marks>=91 && marks<=100)
    {
        printf("your grade is A+");
    }
    else
    {
        printf("invalid");
    }
    return 0;

}

Program Output:






For more problems click here


PROBLEM 39:
Prompt the user for his/her year of birth and if the year is a leap year print “You were born in a leap year”, otherwise print the age of the user. (leap.c)

CODE:

#include<stdio.h>
main()
{
// Variable declaration//
int year;
int present_year=2016;
/*Input*/
printf("Enter year:");
scanf("%d",&year);
/* actual Working */
  if(year%4==0)
     {
       printf("You were born in a leap year");
     }
else if(year<=2016 && year%4!=0)
     {
       present_year=present_year-year;
       printf("Your age is:%d",present_year);
     }
    else if(year>2016 || year%4!=0)
    {
        printf("we cannot tell you the age because its above than current year\nbut its not a leap year.");
    }
    return 0;
}

PROGRAM OUTPUT:













For more problems click here
PROBLEM 38:

For a student of CS102, take his Quiz #1 marks (out of 5) as input and convert it into percentage marks.

Code:

#include<stdio.h>
main ()
{
float marks;
float score;
printf("enter your quiz marks out of 5:");
scanf("%f",&marks);
score=(marks*100)/5;
printf("your percentage is:%.1f",score);
return 0;

}
Program Output:









For more problems click here
PROBLEM 37:

Write a program that prompts the user for the radius of a sphere and prints its volume. [volume of Sphere=(4/3) * pi * radius3].

Code:

#include<stdio.h>
main ()
{
float radius;
float volume;
printf("Enter radius:");
scanf("%f",&radius);
volume=(4*3.14159*radius*radius*radius)/3;
printf("volume of Sphere is:%f",volume);

return 0;

}

Program Output:













For more problems click here

PROBLEM 36:

Write a program that takes input of temperature in Celsius and converts it into Fahrenheit and prints the result.

CODE:

#include<stdio.h>
main ()
{
float temp;
float ans;
printf("enter temperature in celsius:");
scanf("%f",&temp);
ans=temp*9/5+32;
printf("your temperature in fehrenheit is:%f",ans);
return 0;
}


PROGRAM OUTPUT:









For more problems click here
PROBLEM 35:
Input two characters and swap their values.
Code:

#include<stdio.h>
main ()
{
char a;
char b;
char c;
printf("Enter two any  charcter:");
scanf("%c %c",&a,&b);
printf("you enter first character is '%c' and second is '%c'\n",a,b);
c=b;
b=a;
printf("************after snaaping*********\n");
printf("after snap your first character is '%c' and second is '%c'",c,b);
return 0;
}

Program Output:






For more problems click here