Why programs ?
Programming is nothing but making the computers think the same way a human thinks. Programs are made for obtaining a specific solution which can even be solved by humans which when solved by us may consume time. So one thing is clear that man can do all things that a computer can do where in turn a computer can not do all things that a man can do. Even though the computers are fast,reliable,and robust they are simply current consuming machines unless they are programmed.
4 Comments
#include<stdio.h>
void main()
{
int n;
do
{
printf("How many lines you want to printn");
scanf("%d",&n);
}
while((n<1)||(n>9));
for(int i=1;i<=n;i++)
{
for(int j=1;j<=(n-i);j++)
printf(" ");
for(j=1;j<=i;j++)
printf("%d",j);
for(j=(i-1);j>=1;j--)
printf("%d",j);
printf("n");
}
}
I am printing 2n series up to 210
This will be the output of the above code
int main()
{
int i;
for(i=0;i<10;i++)
printf("%d\n",1<<i);
return 0;
}
This will be the output of the above code
1
2
4
8
16
32
64
128
256
512int i=2;
int main()
{
extern int i;
clrscr();
printf("%d",i);
getch();
return 0;
}
int i=3;
#include
void main(){
int check=2;
switch(check){
case 1: printf("D.W.Steyn");
case 2: printf(" M.G.Johnson");
case 3: printf(" Mohammad Asif");
default: printf(" M.Muralidaran");
}
}
(A) M.G.Johnson
(B) M.Muralidaran
(C) M.G.Johnson Mohammad Asif M.Muralidaran
(D) Compilation error
(E) None of the above
output - (c)
void main(){
int check=2;
switch(check){
case 1: printf("D.W.Steyn");
case 2: printf(" M.G.Johnson");
case 3: printf(" Mohammad Asif");
default: printf(" M.Muralidaran");
}
}
(A) M.G.Johnson
(B) M.Muralidaran
(C) M.G.Johnson Mohammad Asif M.Muralidaran
(D) Compilation error
(E) None of the above
output - (c)
#include
#define a 10
main()
{
#define a 50
printf("%d",a);
}
Answer:
50
Explanation:
The preprocessor directives can be redefined anywhere in the program. So the most recently
assigned value will be taken.
main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}
Answer:
H
Explanation:
* is a dereference operator & is a reference operator. They can be applied any number of
times provided it is meaningful. Here p points to the first character in the string "Hello". *p
dereferences it and so its value is H. Again & references it to an address and * dereferences
it to the value H.
main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
}
Answer:
i = -1, +i = -1
Explanation:
Unary + is the only dummy operator in C. Where-ever it comes you can just ignore it just
because it has no effect in the expressions (hence the name dummy operator).
Posted by sharmi
#define a 10
main()
{
#define a 50
printf("%d",a);
}
Answer:
50
Explanation:
The preprocessor directives can be redefined anywhere in the program. So the most recently
assigned value will be taken.
main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}
Answer:
H
Explanation:
* is a dereference operator & is a reference operator. They can be applied any number of
times provided it is meaningful. Here p points to the first character in the string "Hello". *p
dereferences it and so its value is H. Again & references it to an address and * dereferences
it to the value H.
main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
}
Answer:
i = -1, +i = -1
Explanation:
Unary + is the only dummy operator in C. Where-ever it comes you can just ignore it just
because it has no effect in the expressions (hence the name dummy operator).
Posted by sharmi
main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
Answer:
5 4 3 2 1
Explanation:
When static storage class is given, it is initialized once. The change in the value of a static
variable is retained even between the function calls. Main is also treated like any other ordinary function,
which can be called recursively.
Posted by sharmi
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
Answer:
5 4 3 2 1
Explanation:
When static storage class is given, it is initialized once. The change in the value of a static
variable is retained even between the function calls. Main is also treated like any other ordinary function,
which can be called recursively.
Posted by sharmi
Short circuit operator is operator in which first operand of expression is evaluated , the second operand is evaluated if it is necessary.
Short circuit operators in c programming are &&(Logical AND), ||(Logical OR).
Logical AND:
In logical AND operator expression if the first operand is false then it is no need of evaluating the second operand.
Logical OR:
In Logical OR operator expression if the first operand is true then it is no need of evaluating the second operand.
AND operator example
OR operator example
Short circuit operators in c programming are &&(Logical AND), ||(Logical OR).
Logical AND:
In logical AND operator expression if the first operand is false then it is no need of evaluating the second operand.
Logical OR:
In Logical OR operator expression if the first operand is true then it is no need of evaluating the second operand.
AND operator example
OR operator example
extern int a;Answer:
int ss();
int main()
{
int a=10;
ss();
return printf("%d",a);
}
int ss()
{
return printf("%d",a);
}
int a=20;
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
Read Full Article »
for (i=0;i<5;i++)
{
if(i%3==0)
continue;
}
i=0;
while(i<5)
{
if(i%3==0)
continue;
i++;
}
Answer:
Here is the program which use bit wise operator and perform the addition operation. There is no arithmetic operator is used in this program.
Read Full Article »
int main()
{
int a,b,sum,carry;
printf("Enter the values");
scanf("%d %d",&a,&b);
sum=a^b;
carry=a&b;
while(carry!=0)
{










