1.What will be the output of the program? Explanation: Step 1: const char *s = “”; The constant variable s is declared as an pointer to an array of characters type and initialized with an empty string. Step 2: char str[] = “Hello”; The variable str is declared as an array of charactrers type and initialized with a string “Hello”. Step 3: s = str; The value of the variable str is assigned to the variable s. Therefore str contains the text “Hello”. Step 4: while(*s){ printf(“%c”, *s++); } Here the while loop got executed untill the value of the variable s is available and it prints the each character of the variable s. Hence the output of the program is “Hello”. 2.What will be the output of the program (sample.c) given below if it is executed from the command line? Explanation: So it prints *.c 3.What will be the output of the program? Explanation: Function atoi() converts the string to integer. result1 = result1+atoi(i); result2 = result2+atof(i);#include<stdio.h> int main() { const char *s = ""; char str[] = "Hello"; s = str; while(*s) printf("%c", *s++); return 0; }
cmd> sample “*.c”/* sample.c */ #include<stdio.h> int main(int argc, int *argv) { int i; for(i=1; i<argc; i++) printf("%sn", argv[i]); return 0; }
argc=2
argv[0]=sample
argv[1]=*.c#include<stdio.h> #include<stdlib.h> int main() { char *i = "55.555"; int result1 = 10; float result2 = 11.111; result1 = result1+atoi(i); result2 = result2+atof(i); printf("%d, %f", result1, result2); return 0; }
Function atof() converts the string to float.
Here result1 = 10 + atoi(55.555);
result1 = 10 + 55;
result1 = 65;
Here result2 = 11.111 + atof(55.555);
result2 = 11.111 + 55.555000;
result2 = 66.666000;
So the output is “65, 66.666000” .
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算