BCA C Programing Important Question from Unit 6th(File Handling) for CSJM University Exam 2nd Semester


UNIT-6
 FILE HANDLING

Q1- What is ment by opening a data file and closing a data file?

Q2- Explain all the file mode
(a).r
 (b). w
 (c). a
 (d). a+
 (e). w+
 (f). r+

Q3- Explain it
(a). fopen()
(b). fclose()
(c). fseek()
(d). fgetc()
(e). fputs()
(f). fgets().
(g). ftell()
(h) getc()
(i) putc().

Q4. Write a Program to copy a file into another but in reverse order.

Q5. Write the basic steps of file handling?

BCA C Programing Important Question from Unit 4th(Structures and Union) for CSJM University Exam 2nd Semester


UNIT-4
STRUCTURES & UNION

Q1- What is structure? How we define it. Explain with the help of suitable Example?
Q2- What is Union? How we define it. Explain with the help of suitable Example?
Q3- Write a short note on nested Structure?
Q4- Write the difference between Union and Structure?

BCA C Programing Important Question from Unit 5th(C preprocessor) for CSJM University Exam 2nd Semester


UNIT-5
INTRODUCTION OF C PROCESSOR & BITWISE OPERATORS

Q1- Define Preprocessor Directive? Explain all the types of preprocessor directive?
Q2- What is Conditional Compilation Directive? Explain there types and write there function.
Q3- Write a program to create macro definitions with arguments to calculate area and perimeter of a      Circle , Triangle and Square.
Q4- Define Bitwise operators? And write one-one(example of right shift and left shift operator?
Q5- Explain command line arguments? Give the complete proto type of the main function and explain it’s arguments?
Q6- Write to program display the command line argument values.

BCA C Programing Important Question from Unit 3rd(String) for CSJM University Exam 2nd Semester


Unit -3 (String)


1   Write a Program to Convert a Lower case String to Upper case String.
2     How we Initialized a String?
3     What is String? and Explain Null Character and why is it important?
4     Explain (a). strlen()  (b). strcpy() (c). strcmp() (d). strcat() function with Suitable example?
5     Write a Program to sort a input String using standard library function?
6     Write a Program to Reverse String without using any library function?
7     Write a Program to find the length of a String without using library Function?
8     Write a Program to Compare String without using Strcmp() function.
9     Write a Program to check the Given String is Palindrome or not?

BCA C Programing Important Question from Unit 2nd(Pointer) for CSJM University Exam 2nd Semester



Unit- 2 (POINTER)
1.   Explain the Relation Between an Array and Pointer?
2.   What is Pointer? Explain their Features and What is use of (*) Indirection Operator?
3.   Write the use of
(a). calloc()
(b). malloc()
(c). free()
(d). realloc() with suitable examples?

4. Write a Program to Swap Two numbers using Call by Reference?
5. Write a difference between “call by value” and “call by reference” with suitable examples?
OR
     Explain types of function calling in c with example?
6. What is Dynamic memory Allocation? Explain briefly?
OR
Explain with the example the concept of Garbage Collection?
7. Write the 5 Advantages And 5 Disadvantages of Pointer?
8. Explain the Arithmetic Operation Supported by Pointer?
9. Explain (A). Library function (B). User Define Functions?
10.Write difference between Address Operator(&) and Indirection Operator(*)?

BCA C Programing Important Question from Unit 1st(Array) for CSJM University Exam 2nd Semester



UNIT 1- ARRAYS
1.   Write a program to check the give number is Armstrong or Not?
2.   Explain:  
 (a) for loop 
 (b) while loop 
(c) do while loop.
3.   Write a program to print all prime numbers below 100?
4.   Write a program to calculate the numbers of Years and Months take input as a “days” from the user.
5.   Explain:     
 (a) Arithmetic Operator                                                                                 
 (b) Relational Operator                                                                        
 (c) Logical Operator
6.   Write a program to calculate the Area of Triangle and Area of Circle.
7.   What is Difference between Character Array and Integer Array?
8.   Write a program to sort an Arithmetic Array in increasing order?
9.   What are data types? Explain different types of data types and their size?
    10.    Write a program to even numbers up to 100.
    11.    Write a program to print sum and average of 5 integers digits?
    12.    Write a program to multiply 2*2 Matrices.
  13.    What are arrays? How can they be initialized? Give the Memory       representation of Arrays?                                                                                   OR                           
 What do you mean by Array? How can we declare Arrays?
    14.    Write the difference between Multidimensional Array and one    Dimensional Array?
    15.    Write a program to Add and Subtraction of 2 Matrix take Input from    the user?
   16.    What is Multidimensional Array? Explain with suitable Example?  

17.  What Are Subscripts? How are they written? And write there  Restrictions apply to the values?
18. Write a program to find Largest and Smallest in an Array?
19. Write a program to find the Determinant of 3*3 Matrix? 
20Write a program to Inverse of a matrix?

 
 

PHP DAY 17(PHP - Sending Emails using PHP)

PHP - Sending Emails using PHP

PHP must be configured correctly in the php.ini file with the details of how your system sends email. Open php.ini file available in /etc/ directory and find the section headed [mail function].
Windows users should ensure that two directives are supplied. The first is called SMTP that defines your email server address. The second is called sendmail_from which defines your own email address.
The configuration for Windows should look something like this −
[mail function]
; For Win32 only.
SMTP = smtp.secureserver.net
 
; For win32 only
sendmail_from = webmaster@tutorialspoint.com

Linux users simply need to let PHP know the location of their sendmail application. The path and any desired switches should be specified to the sendmail_path directive.
The configuration for Linux should look something like this −
[mail function]
; For Win32 only.
SMTP = 
 
; For win32 only
sendmail_from = 
 
; For Unix only
sendmail_path = /usr/sbin/sendmail -t -i
Now you are ready to go −

 

Sending plain text email

PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters.
mail( to, subject, message, headers, parameters );
Here is the description for each parameters.
Sr.No
Parameter & Description
1
to
Required. Specifies the receiver / receivers of the email
2
subject
Required. Specifies the subject of the email. This parameter cannot contain any newline characters
3
message
Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters
4
headers
Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n)
5
parameters
Optional. Specifies an additional parameter to the send mail program
As soon as the mail function is called PHP will attempt to send the email then it will return true if successful or false if it is failed.
Multiple recipients can be specified as the first argument to the mail() function in a comma separated list.

 

Sending HTML email

When you send a text message using PHP then all the content will be treated as simple text. Even if you will include HTML tags in a text message, it will be displayed as simple text and HTML tags will not be formatted according to HTML syntax. But PHP provides option to send an HTML message as actual HTML message.
While sending an email message you can specify a Mime version, content type and character set to send an HTML email.

Example

Following example will send an HTML email message to xyz@somedomain.com copying it to afgh@somedomain.com. You can code this program in such a way that it should receive all content from the user and then it should send an email.
<html>
   
   <head>
      <title>Sending HTML email using PHP</title>
   </head>
   
   <body>
      
      <?php
         $to = "xyz@somedomain.com";
         $subject = "This is subject";
         
         $message = "<b>This is HTML message.</b>";
         $message .= "<h1>This is headline.</h1>";
         
         $header = "From:abc@somedomain.com \r\n";
         $header .= "Cc:afgh@somedomain.com \r\n";
         $header .= "MIME-Version: 1.0\r\n";
         $header .= "Content-type: text/html\r\n";
         
         $retval = mail ($to,$subject,$message,$header);
         
         if( $retval == true ) {
            echo "Message sent successfully...";
         }else {
            echo "Message could not be sent...";
         }
      ?>
      
   </body>
</html>

 

Sending attachments with email

To send an email with mixed content requires to set Content-type header to multipart/mixed. Then text and attachment sections can be specified within boundaries.
A boundary is started with two hyphens followed by a unique number which can not appear in the message part of the email. A PHP function md5() is used to create a 32 digit hexadecimal number to create unique number. A final boundary denoting the email's final section must also end with two hyphens.
<?php
   // request variables // important
   $from = $_REQUEST["from"];
   $emaila = $_REQUEST["emaila"];
   $filea = $_REQUEST["filea"];
   
   if ($filea) {
      function mail_attachment ($from , $to, $subject, $message, $attachment){
         $fileatt = $attachment; // Path to the file
         $fileatt_type = "application/octet-stream"; // File Type 
         
         $start = strrpos($attachment, '/') == -1 ? 
            strrpos($attachment, '//') : strrpos($attachment, '/')+1;
                                                                                 
         $fileatt_name = substr($attachment, $start, 
            strlen($attachment)); // Filename that will be used for the 
            file as the attachment 
         
         $email_from = $from; // Who the email is from
         $subject = "New Attachment Message";
         
         $email_subject =  $subject; // The Subject of the email 
         $email_txt = $message; // Message that the email has in it 
         $email_to = $to; // Who the email is to
         
         $headers = "From: ".$email_from;
         $file = fopen($fileatt,'rb'); 
         $data = fread($file,filesize($fileatt)); 
         fclose($file); 
         
         $msg_txt="\n\n You have recieved a new attachment message from $from";
         $semi_rand = md5(time()); 
         $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
         $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . "
            boundary=\"{$mime_boundary}\"";
         
         $email_txt .= $msg_txt;
                                                             
         $email_message .= "This is a multi-part message in MIME format.\n\n" . 
            "--{$mime_boundary}\n" . "Content-Type:text/html; 
            charset = \"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . 
            $email_txt . "\n\n";
                                                                                 
         $data = chunk_split(base64_encode($data));
         
         $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" .
            " name = \"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . 
            //" filename = \"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: 
            base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
                                                                                  
         $ok = mail($email_to, $email_subject, $email_message, $headers);
         
         if($ok) {
            echo "File Sent Successfully.";
            unlink($attachment); // delete a file after attachment sent.
         }else {
            die("Sorry but the email could not be sent. Please go back and try again!");
         }
      }
      move_uploaded_file($_FILES["filea"]["tmp_name"],
         'temp/'.basename($_FILES['filea']['name']));
                                                             
      mail_attachment("$from", "youremailaddress@gmail.com", 
         "subject", "message", ("temp/".$_FILES["filea"]["name"]));
   }
?>
 
<html>
   <head>
      
      <script language = "javascript" type = "text/javascript">
         function CheckData45() {
            with(document.filepost) {
               if(filea.value ! = "") {
                  document.getElementById('one').innerText = 
                     "Attaching File ... Please Wait";
               }
            }
         }
      </script>
      
   </head>
   <body>
      
      <table width = "100%" height = "100%" border = "0" 
         cellpadding = "0" cellspacing = "0">
         <tr>
            <td align = "center">
               <form name = "filepost" method = "post" 
                  action = "file.php" enctype = "multipart/form-data" id = "file">
                  
                  <table width = "300" border = "0" cellspacing = "0" 
                     cellpadding = "0">
                                                                                                                                              
                     <tr valign = "bottom">
                        <td height = "20">Your Name:</td>
                     </tr>
                     
                     <tr>
                        <td><input name = "from" type = "text" 
                           id = "from" size = "30"></td>
                     </tr>
                     
                     <tr valign = "bottom">
                        <td height = "20">Your Email Address:</td>
                     </tr>
                     
                     <tr>
                        <td class = "frmtxt2"><input name = "emaila"
                           type = "text" id = "emaila" size = "30"></td>
                     </tr>
                     
                     <tr>
                        <td height = "20" valign = "bottom">Attach File:</td>
                     </tr>
                     
                     <tr valign = "bottom">
                        <td valign = "bottom"><input name = "filea" 
                           type = "file" id = "filea" size = "16"></td>
                     </tr>
                     
                     <tr>
                        <td height = "40" valign = "middle"><input 
                           name = "Reset2" type = "reset" id = "Reset2" value = "Reset">
                        <input name = "Submit2" type = "submit" 
                           value = "Submit" onClick = "return CheckData45()"></td>
                     </tr>
                  </table>
                  
               </form>
               
               <center>
                  <table width = "400">
                     
                     <tr>
                        <td id = "one">
                        </td>
                     </tr>
                     
                  </table>
               </center>
               
            </td>
         </tr>
      </table>
      
   </body>

</html>

ITI (Trade - COPA) Day-23

ITI COPA (Computer Operator & Programming Assistant) – Basic Notes TOPIC- PROGRAMMING LANGUAGE – PYTHON 1. Introduction to Programming...