Professional Documents
Culture Documents
Homework-1
Submitted By:
Section: E - 3004
Roll_No: RE3004B77
Group: 2
Course_code: 1604
Date_Of_Submission: 31/08/2010
Submitted To:
Ans : -
Precedence: Precedence is the priority for grouping different types of
operators with their operands.
a+b*c/d
The ‘*’ and ‘/’ operations are performed before ‘+’ because of precedence
b = 9;
c = 5;
a = b = c;
Q2. Differentiate between Implicit and Explicit Type Conversions?
Ans: -
Implicit Type Conversion: Implicit conversions do not require any
operator. They are automatically performed when a value is copied to a
compatible type.
Example:
double d;
long l;
int i;
if (d > i) d = i;
if (i > l) l = i;
if (d == l) d *= 2;
Int a, b, c;
Float avg;
Avg= (float) (a+b+c)/3;
Q3. Differentiate between the following
1. Prefix and Postfix increment operator.
2. Assignment and Equal To operator.
3. Expression and Statement
4. Identifiers and Keywords.
5. Signed and Unsigned Integer.
1.
Prefix: The prefix form is when we put the operator before the variable
containing the number. If we use the prefix form then the number is
incremented before it is evaluated
Example:
Int n=1, a;
a=++n;
printf (“%d”, a); Output: 2
Postfix: The postfix form is when we put the operator after the variable
containing the number. If we use the postfix form then the number is
incremented after it is evaluated
Example:
Int n=1, a;
a=n++;
printf (“%d”, a); Output: 1
2.
Assignment Operator: The Assignment Operator evaluates an expression
on the right of the expression and substitutes it to the value or variable on
the left of the expression. It is denoted by ‘=’.
Example:
Int a=5, b=6, x;
X=a+b;
Here the value of a + b is evaluated and substituted to the variable x.
3.
4.
Identifiers: Identifiers are user define words that are used to give names
to entities like, variable, array, functions, structure, etc.
Rules for naming identifiers:
Keywords: There are certain words that are reserved for doing special
tasks. These words are known as keywords and they have standard,
predefined meaning in C. They are always written in lowercase.
Types :
i) Standard: There are 32 standard keywords.
auto, char, int, float, .……… , etc
ii) Optional: There are 8 optional keywords.
Ada, asm, entry, pascal, fast, near, far,use
5. Signed & unsigned Integer:
Unsigned: When the qualifier ‘unsigned’ is used the number is always
positive, it’s range is 0 to 65535 and it stored 2 bytes.
signed: When the qualifier ‘signed’ is used the number may be positive or
negative, it’s range is -32768 to 32767 and it also stored 2 bytes.
Example:
#include <stdio.h>
void main()
{
short int i;
short unsigned int j;
j = 60000;
i =j;
printf(“%d \t %d”,i,j);
PART ‘B’
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i;
char ch[50];
clrscr();
printf("Enter size of array(MAX 50): ");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
ch[i]=getchar();
}
printf("\n\n");
for(i=1;i<=n;i++)
{
printf("%c\t%d\n",ch[i],ch[i]);
}
getch();
}
#include<stdio.h>
#include<conio.h>
Void main()
{
int day;
Clrscr();
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
int k,i;
char str[50];
printf("Enter str: ");
gets(str);
k=strlen(str);
for(i=0;i<k;i++)
{
if(str[i]==' ')
printf("\n");
else
printf("%c",str[i]);
}
getch();
}