Skip to content
Snippets Groups Projects
Commit 56494c7a authored by Sibidharan's avatar Sibidharan :speech_balloon:
Browse files

day 5

parent 2f5e32cb
No related branches found
No related tags found
No related merge requests found
No preview for this file type
intstr.c 0 → 100644
#include<stdio.h>
int main()
{
char buf[10];
float x;
printf("Enter a value: ");
scanf("%f",&x);
sprintf(buf,"%f",x);
printf("x value in string: %s",buf);
}
\ No newline at end of file
#include<stdio.h>
#include<stdlib.h>
int main()
{
char inp[]="234";
int x;
x = atoi(inp);
x = x * 10;
printf("Converted data : %d",x);
}
\ No newline at end of file
#include<stdio.h>
struct Point{
int x,y;
};
int main()
{
struct Point p[3];
int i;
for(i=0;i<2;i++){
printf("Enter x & y values: ");
scanf("%d%d",&p[i].x,&p[i].y);
}
p[2].x = p[0].x + p[1].x;
p[2].y = p[0].y + p[1].y;
for(i=0;i<3;i++)
{
printf("P%d (x,y) is : %d,%d\n",i,p[i].x,p[i].y);
}
//printf("Output is P[2] is (x,y) : %d, %d",p[2].x,p[2].y);
}
\ No newline at end of file
#include<stdio.h>
struct Point{
int x,y;
};
int main()
{
struct Point P1,P2,P3;
P1.x= 20;
P1.y = 30;
P2.x = 40;
P2.y = 60;
P3.x = P1.x + P2.x;
P3.y = P1.y + P2.y;
printf("P3 (x,y) : %d,%d",P3.x,P3.y);
}
\ No newline at end of file
union1.c 0 → 100644
#include<stdio.h>
struct Dt1{
int x;
char s[40];
};
union Dt2{
int y;
char s1[40];
};
int main()
{
struct Dt1 sd1;
union Dt2 ud2;
printf("size of Dt1 (struct): %ld bytes\n",sizeof(sd1));
printf("size of Dt2 (union): %ld bytes",sizeof(ud2));
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment