amaresh@Hare-Krishna:~$ cat swp.c
#include<stdio.h>
int
main(){
int a=5,b=6; // Compile using gcc -Wall
#ifdef DEBUG // to avoid compiler warnings
a ^=b^=a^=b;
#endif
printf("value of a is %d and b is %d\n",a,b);
return 0;
}
Write an implementation of float stringToFloat(char *str).
The code should be simple, and not require more than the
basic operators (if, for, math operators, etc.).
Assumptions
Dont worry about overflow or underflow
Stop at the 1st invalid character and return the number
you have converted till then, if the 1st character is
invalid return 0
Dont worry about exponential (e.g. 1e10), instead you
should treat e as an invalid character
Write it like real code, e.g. do error checking
Go though the string only once
Examples
1.23 should return 1.23
1a should return 1
ashould return 0
44.what is the difference between strcpy() and memcpy()
function?
45.what is output of the following statetment?
46.Printf(%x, -1<<4); ?
47.will the program compile?
int i;
scanf(%d,i);
printf(%d,i);
48.write a string copy function routine?
49.swap two integer variables without using a third
temporary variable?
50.how do you redirect stdout value from a program to a file?
51.write a program that finds the factorial of a number
using recursion?
what will be the result of the following program ?
char *gxxx()
{
static char xxx[1024];
return xxx;
}
main()
{
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is :
%s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Write a program that accepts a string where multiple spaces
are given in between the words. Print the string ignoring
the multiple spaces.
Example:
Input: We.....Are....Student Note: one .=1 Space
Output: "We Are Student"