Search
Log in
Latest topics
Statistics
We have 30 registered usersThe newest registered user is deigavr
Our users have posted a total of 191 messages in 126 subjects
Who is online?
In total there are 2 users online :: 0 Registered, 0 Hidden and 2 Guests None
Most users ever online was 125 on Wed Apr 07, 2021 9:18 am
3rd program
Page 1 of 1
3rd program
Theory
“A variable is a space in the computer’s memory set aside for a certain kind of data and given a name for easy reference.”
Variables may be the most fundamentals aspect of any computer language. Variables are used so that the same space in memory can hold different values at different times. For instance, suppose you are writing a program to calculate someone’s paycheck, you will need to store at least the hourly rate and the hours worked. If you want to do the calculation for more than one employee, you will need to use the same program and the same spaces in memory to store similar data for additional employees. A variable is a space in memory that plays the same role many times, but may contain a different value each time.
Task:
1. Write a program that takes your age as input and calculate the total number of hours old?
#include<stdio.h>
void main(void)
{
int a,h;
printf("ENTER YOUR AGE ");
scanf("%d",&a);
h=8760*a;
printf("YOU ARE %d HOURS OLD\n",h);
}
2. Write a program that takes two integers as input, perform the following and print the result.
a + b , a – b , a * b , a / b
#include<stdio.h>
void main(void)
{
int p,o,i,t,u,j;
printf("ENTER 1st Integer\n");
scanf("%d",&i);
printf("ENTER 2nd Integer\n");
scanf("%d",&j);
p=i+j;
o=i-j;
t=i*j;
u=i/j;
printf("1st %d\n",p);
printf("2nd %d\n",o);
printf("3rd %d\n",t);
printf("4th %d\n",u);
}
“A variable is a space in the computer’s memory set aside for a certain kind of data and given a name for easy reference.”
Variables may be the most fundamentals aspect of any computer language. Variables are used so that the same space in memory can hold different values at different times. For instance, suppose you are writing a program to calculate someone’s paycheck, you will need to store at least the hourly rate and the hours worked. If you want to do the calculation for more than one employee, you will need to use the same program and the same spaces in memory to store similar data for additional employees. A variable is a space in memory that plays the same role many times, but may contain a different value each time.
Task:
1. Write a program that takes your age as input and calculate the total number of hours old?
#include<stdio.h>
void main(void)
{
int a,h;
printf("ENTER YOUR AGE ");
scanf("%d",&a);
h=8760*a;
printf("YOU ARE %d HOURS OLD\n",h);
}
2. Write a program that takes two integers as input, perform the following and print the result.
a + b , a – b , a * b , a / b
#include<stdio.h>
void main(void)
{
int p,o,i,t,u,j;
printf("ENTER 1st Integer\n");
scanf("%d",&i);
printf("ENTER 2nd Integer\n");
scanf("%d",&j);
p=i+j;
o=i-j;
t=i*j;
u=i/j;
printf("1st %d\n",p);
printf("2nd %d\n",o);
printf("3rd %d\n",t);
printf("4th %d\n",u);
}
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Mon Aug 01, 2011 11:44 pm by Guest
» Netbook Brands
Mon Aug 01, 2011 5:39 am by Guest
» backlinks checker backlink service
Sun Jul 31, 2011 8:56 am by Guest
» how to buy facebook fans f4
Sat Jul 30, 2011 2:34 pm by Guest
» Alle bijzondere dingen in de zaanstreek
Sat Jul 30, 2011 8:11 am by Guest
» HERE YOU CAN POST ALL WEBSITE LINKS...
Wed Aug 26, 2009 2:16 pm by onesimpletech
» cool web site for all must check it
Mon Jul 06, 2009 2:32 pm by Snopy Cobra
» poetry spirit
Mon Jul 06, 2009 2:31 pm by Snopy Cobra
» best to learn VC++
Sun May 10, 2009 3:22 pm by Guest